package tmproject.hlhj.fhp.cartrans.customVIews

import android.content.Context
import android.content.pm.ActivityInfo
import android.view.LayoutInflater
import android.widget.LinearLayout
import android.widget.PopupWindow
import kotlinx.android.synthetic.main.dialog_sign.view.*
import tmproject.hlhj.fhp.cartrans.BaseAty
import tmproject.hlhj.fhp.cartrans.R
import tmproject.hlhj.fhp.cartrans.utils.CutUtils

/**
 * Created by Administrator on 2018/8/30/030.
 */
class SignPop(private val c:Context,private val listener: SignDialog.OnSignOverListener) :PopupWindow(c) {
    private val TAKE_PHOTO=111

    init {
        this.width=LinearLayout.LayoutParams.MATCH_PARENT
        this.height=LinearLayout.LayoutParams.WRAP_CONTENT
//        this.isFocusable=true
        initPop()
    }

    private fun initPop() {
        contentView=LayoutInflater.from(c).inflate(R.layout.dialog_sign,null)
        contentView.drawBack.clear()
        contentView.getBitmap.setOnClickListener {
            val aty = c as BaseAty<*,*>
            aty.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT)
            val bitmap = CutUtils.loadBitmapFromViewBySystem(contentView.drawBack)
            listener.over(bitmap!!)
            contentView.getBitmap.postDelayed(Runnable {
                dismiss()
            },500)
        }

        contentView.btClear.setOnClickListener {
            contentView.drawBack.clear()
        }

    }
}